package com.haredot.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.haredot.entity.Resource;
import com.haredot.entity.ResourceDownloadHistory;
import com.haredot.vo.AttentionUserVo;
import com.haredot.vo.ResourceDetailVo;
import com.haredot.vo.ResourceViewVo;
import com.haredot.vo.ResourceVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
* @author Administrator
* @description 针对表【tb_resource】的数据库操作Mapper
* @createDate 2023-09-02 22:00:46
* @Entity com.haredot.entity.Resource
*/
@Mapper
public interface ResourceMapper extends BaseMapper<Resource> {
    /**
     * 查询 前12条 精选资源，并按照时间降序排列
     * @return
     */
    List<ResourceViewVo> queryCoreResourcesTop12();

    ResourceDetailVo queryResourceDetail(@Param("resId") Long resId, @Param("userId") Long userId);

    List<AttentionUserVo> findAttentionTop9(@Param("userId") Long userId);

    /**
     * 根据资源类型、分页查询获取资源信息
     * @param page
     * @param typeId
     * @return
     */
    Page<ResourceViewVo> findResourcesByTypeIdAndPage(Page<Page<Map<String, Object>>> page, @Param("typeId") Long typeId);

    Long findMoreResourceByUidCount(@Param("userId") Long uid);

    List<ResourceVo> findMoreResourceByUid(@Param("offset") Long offset, @Param("rows") Long rows, @Param("userId")Long userId);

    long findDownloadHistoryCountLast30Days(@Param("userId") Long userId, @Param("resId") Long resId);

    int saveDownloadHistory(ResourceDownloadHistory history);
}




